package com.bytenebula.asteroid.entity.vo;

import com.bytenebula.asteroid.entity.MetaDatabase;
import com.bytenebula.asteroid.entity.dto.MetaDatabaseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

@EqualsAndHashCode(callSuper = true)
@Data
public class MetaDatabaseVO extends MetaDatabase {

    public MetaDatabaseVO(MetaDatabaseDTO dto) {
        BeanUtils.copyProperties(dto, this);
        if (dto.getOwner() != null)
            this.ownerName = dto.getOwner().getName();
        if (dto.getCreateUser() != null)
            this.createUserName = dto.getCreateUser().getName();
        if (dto.getLastModifiedUser() != null)
            this.lastModifiedUserName = dto.getLastModifiedUser().getName();
    }

    private String ownerName;
    private String createUserName;
    private String lastModifiedUserName;
}
